
export async function responseInterceptor(res,flag){
    let code = 0
    if(flag === 'body'){
        code  = res.status
    }else{
        code = res?.code
    }

    switch(code){
        case 200:
            if(flag === 'body'){
                return res?.body
            }
            return res?.data
        case 403:
            if(flag === 'body'){
                let resjson = await res.json()
                alert(resjson?.message)
            }else{
                alert(res?.message)
            }
            window.location.href = 'login'
            return 
        default:
            if(flag === 'body'){
                let resjson = await res.json()
                alert(resjson?.message)
            }else{
                alert(res?.message)
            }
    }
}